#!/bin/bash
echo "Building and setting PATH for DLLs..."
echo

WXWIN="/d/vc/wxWidgets-3.2.7"

# 编译程序
echo "Compiling AI system..."
g++ -std=c++11 -O2 -Wall -Wextra \
    -I"$WXWIN/include" \
	-I "$WXWIN/lib/wx/include/msw-unicode-3.2" \
    -D__WXMSW__ -D_UNICODE -DUNICODE \
    src/working_ai_system.cpp \
    -L"$WXWIN/lib" \
    -lwxmsw32u_core_gcc_custom -lwxbase32u_gcc_custom \
    -lkernel32 -luser32 -lgdi32 -lwinspool -lcomdlg32 \
    -ladvapi32 -lshell32 -lole32 -loleaut32 -luuid \
    -lcomctl32 -lrpcrt4 -loleacc -luxtheme \
    -o cbp2make_ai.exe

if [[ $? -eq 0 ]]; then
    echo "✅ Compilation successful!"
    echo "Executable: cbp2make_ai.exe"
    
    # 设置 PATH 环境变量包含 wxWidgets DLL 目录
    export PATH="$WXWIN/lib:$PATH"
    echo "📁 Added to PATH: $WXWIN/lib"
    
    echo "Testing with PATH set..."
    ./cbp2make_ai.exe --status
    
    echo
    echo "💡 To run manually, set PATH first:"
    echo "   export PATH=\"$WXWIN/lib:\$PATH\""
    echo "   ./cbp2make_ai.exe"
else
    echo "❌ Compilation failed"
    exit 1
fi
